package com.github.sbb.sherry.primitives.config.fetcher;

import com.github.sbb.sherry.common.base.Preconditions;
import com.github.sbb.sherry.common.base.ValidateResult;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@NoArgsConstructor
@ToString
public class MongoDBFetcherConfig extends FetcherConfig {

  private String collection;
  private String condition;
  private int limit = -1;

  @Override
  public ValidateResult validate() {
    try {
      Preconditions.checkNotBlank(collection, "collection 不能为空");
      Preconditions.checkNotBlank(condition, "condition 不能为空");
    } catch (Exception e) {
      return new ValidateResult(false, e.getMessage());
    }
    return new ValidateResult(true, null);
  }
}
